
{

    $group:
    {
        _id: "$ParentGroupId",
      
            Total_avg: { $avg: "$CompanyScore" },
            Total_min: { $min: "$CompanyScore" },
            Total_max: { $max: "$CompanyScore" },
            
            E_avg: { $avg: "$E.Score" },
            E_min: { $min: "$E.Score" },
            E_max: { $max: "$E.Score" },

            G_avg: { $avg: "$G.Score" },
            G_min: { $min: "$G.Score" },
            G_max: { $max: "$G.Score" },

            S_avg: { $avg: "$S.Score" },
            S_min: { $min: "$S.Score" },
            S_max: { $max: "$S.Score" },

            P_avg: { $avg: "$P.Score" },
            P_min: { $min: "$P.Score" },
            P_max: { $max: "$P.Score" },

            GroupCount: { $sum: 1 },
            groupNames: { $addToSet: "$PeerGroupName" },
        
         companies: {$push: "$$ROOT" }
    }
}